<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>会员登录</title>
<link href="${ctx }/style/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx }/js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="${ctx }/js/common.js"></script>

<script type="text/javascript">

	function checkLogin()
	{
      var username = $("#j_username").val();
	  if(!checkMobilePhone(username)){
		  $("#j_username").focus();
		  alert("请正确填写手机号码。");
		  return false;
	  }

      var j_password = $("#j_password").val();
      if(j_password == ""){
    	  alert("请填写用户密码。");
    	  $("#j_password").focus();
          return false;
      }

      var _captcha_parameter = $("#_captcha_parameter").val();
      if(_captcha_parameter == ""){
    	  alert("请填写验证码。");
    	  $("#_captcha_parameter").focus();
          return false;
      }

      if($("#cb_SaveName").attr("checked")==true){
    	  setCookie("kg_customer",username,7*24*3600,null,"/",true);
      }

      $("#loginForm").submit();
	}

	/***** 忘记密码 ******/
	function forgetpwd(){
		var u_name = $("#j_username").val();
		  if(u_name == ""){
			  $("#j_username").focus();
			  alert("请正确填写手机号码。");
			  return false;
		  }
		location.href = "${ctx }/customer/forgetpwd.do?userType=1&u_name="+u_name;
	}

	function refreshImage()
	{
		var imgObj = document.getElementById("captcha");
		imgObj.src = "${ctx}/servlet/captcha.jpg?" + new Date().getTime();
	}

	function init_message(){

		var errorMessage = '${requestScope.errormessge}';

		if(errorMessage != ''){
			alert(errorMessage);
		}
	}

	$(function(){
		var uName = getCookie("kg_customer");
		$("#j_username").val(uName);
		init_message();
	});

</script>

<style TYPE="text/css">
#main{margin: 0 auto;width: 960px;height: 400px;background: url("${ctx}/images/login/background.jpg");overflow: auto;border: 1px solid #ccc;margin-top: 5px;}
#content{margin: 30px 0px 0px 30px;}
.bt14A {font-family: "宋体";font-size: 14px;line-height: 25px;color: #666666;padding: 5px 5px 5px 5px;}
.nw12a {font-family: "宋体";font-size: 12px;line-height: 22px;color: #000000;padding: 5px 10px 5px 10px;}
.input{border: 1px solid #cccccc;-moz-border-radius: 3px;-webkit-border-radius: 3px;height: 18px;line-height: 17px;padding: 8px 5px 7px;width: 200px;font-size: 14px;}
</style>

</head>

<body>

<%@include file="/commons/head.jsp"%>

<div id="main">

  <div style="margin: 40px 0px 0px 75px;">
		<span><img src="${ctx }/images/login.gif" style="vertical-align: bottom;"/></span>
  </div>
  <div id="content">
	<form action="${ctx }/customer/customerAction!login.do" method="post" name="loginForm" id="loginForm" style="margin: 0;padding: 0">
		<table border="0" cellpadding="3" cellspacing="5" width="100%">
		  <tr>
		    <td class="bt14A" align="right">手机号</td>
		    <td><input type="text" name="j_username" id="j_username" class="input"></td>
		  </tr>
		  <tr>
			  <td class="bt14A" align="right">密码</td>
			  <td>
			  	<div style="float: left;">
			  		<input type="password" name="j_password" id="j_password" class="input">
			  	</div>
			  	 <div style="padding: 10px 0px 0px 10px;float: left;">
			      	<span class="nw12a"><a href="javascript:forgetpwd()">忘记密码？</a></span>
			     </div>
		      </td>
		  </tr>
		  <tr>
			<td style="font-family: 宋体;font-size: 14px;color: #666666;" align="right">验证码</td>
			<td style="font-family: 宋体;font-size: 14px;">
				<div style="float: left;">
					<input type="text" name="_captcha_parameter" id="_captcha_parameter" size="8" class="input"/>
				</div>
				<div style="padding: 10px 0px 0px 10px;float: left;">
					<img id="captcha" src="${ctx }/servlet/captcha.jpg" title="点击刷新图片" alt="点击刷新图片"
						onclick="javascript:refreshImage();" style="cursor: pointer; border: 0px;vertical-align: middle;"/>
						<a onclick="javascript:refreshImage();" href="javascript:void(0);"><span style="font-size: 12px;">换一张图</span></a>
				</div>
			</td>
		  </tr>
		  <tr><td></td>
				  <td>
					   <div style="padding-top: 0px;height: auto;line-height: 20px;color: #999;font-size: 12px;float: left;">
					  	 <input id="cb_SaveName" type="checkbox" name="cb_SaveName" checked="checked">
					   </div>
					    <div style="padding-top: 0px;height: auto;line-height: 20px;color: #666666;font-size: 12px;float: left;">
					  	   记住账号
					   </div>
				   </td>
		  </tr>
		  <tr>
			    <td width="125"><input name="backUrl" value="${param.backUrl }" type="hidden" id="backUrl"/></td>
			    <td class="bt14A">
			    	<div style="float: left;">
			     		<input type="button" value="登 录" onclick="javascript:checkLogin();" class="btn_login"/>  
			     	</div>
			     	<div style="float: left;padding-left: 50px;height: 34px;line-height: 34px;">
			     		<a href="${ctx }/customer/customerAction!registerPrepare.do" style="color: blue">新会员注册</a>
			     	</div>
			    </td>
		  </tr>
		</table>
	 </form>
	</div>
</div>	

<%@include file="/commons/foot.jsp"%>

</body>
</html>